<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://www.ecside.org" prefix="ec"%>
<%@page import="com.agileai.util.DateUtil"%>
<%@ page language="java" import="java.util.*"%>
<%@page import="com.agileai.domain.DataRow"%>
<%@page import="java.sql.Timestamp"%>
<jsp:useBean id="pageBean" scope="request" class="com.agileai.hotweb.domain.PageBean"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>项目周报</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script type="text/javascript" src="aeditors/xheditor/xheditor-1.2.2.min.js"></script>
<script type="text/javascript" src="aeditors/xheditor/xheditor_lang/zh-cn.js"></script>
<script type="text/javascript" src="js/jquery.hotkeys.js"></script>
<script type="text/javascript">

 jQuery(document).ready( 
	function () { 
		$('#emailPreviewBanner').mousedown( 
			function (event) { 
				var isMove = true; 
				var abs_x = event.pageX - $('div.emailPreview').offset().left; 
				var abs_y = event.pageY - $('div.emailPreview').offset().top; 
				$(document).mousemove(function (event) { 
					if (isMove) { 
						var obj = $('div.emailPreview'); 
						obj.css({'left':event.pageX - abs_x, 'top':event.pageY - abs_y}); 
						} 
					} ).mouseup( 
						function () { 
							isMove = false; 
					   } ); } ); } 
 ); 
 
(function($) {
    var oldHTML = $.fn.html;
    $.fn.formhtml = function() {
        if (arguments.length) return oldHTML.apply(this,arguments);
        $("input,textarea,button", this).each(function() {
            this.setAttribute('value',this.value);
        });
        if (arguments.length) return oldHTML.apply(this,arguments);
        $("textarea", this).each(function() {
            $(this).html($(this).val());
        });
        
        $(":radio,:checkbox", this).each(function() {
            if (this.checked) this.setAttribute('checked', 'checked');
            else this.removeAttribute('checked');
        });
        $("option", this).each(function() {
            if (this.selected) this.setAttribute('selected', 'selected');
            else this.removeAttribute('selected');
        });
        return oldHTML.apply(this);
    };
})(jQuery);
   	 
function saveWeeklyWork(index){
	actionTypeTagId = "actionType"+index;
	postRequest('weeklyForm'+index,{actionType:'saveWeeklyWork',showSplash:true,onComplete:function(responseText){
		hideSplash();
		if (responseText == 'success'){
			jAlert('保存成功！');	
		}else{
			writeErrorMsg('操作失败');
		} 
	}});	
}

function createTrace(index){
	actionTypeTagId = "actionType"+index;
	postRequest('weeklyForm'+index,{actionType:'createTrace',showSplash:true,onComplete:function(responseText){
		hideSplash();
		if (responseText == 'success'){
			jAlert("生成追踪成功！","信息提示",function(){
				parent.mainFrame.location.reload();
			})
		}else{
			jAlert(responseText);
		} 
	}});	
}

var cahangTypeIndex;
function openEmailPreview(index){
	cahangTypeIndex = index;
	var emailContentId = "emailContent"+index;
	var weeklyTableId = "weeklyTable"+index;
	var emailConten = $('#'+emailContentId).val();
	var weeklyTable = $('#'+weeklyTableId).formhtml();
	var emailTemplateContent ='<%=pageBean.inputValue("emailTemplate")%>';
	document.body.style.overflow="hidden";
	$('#maskLayer').show();
	$('#emailPreview').show();
	$('#emailSubject').val(emailConten+weeklyTable+emailTemplateContent);
	
	var formId = '#weeklyForm'+index;
	var weeklyId = $(formId+" #PWI_ID" ).val();
	$('#emailWeeklyId').val(weeklyId);
}

function closeEmailPreview(){
	document.body.style.overflow="auto";
	$('#emailPreview').hide();
	$('#maskLayer').hide();
	$('#emailSubject').val();
}

function sendEmail(){
	$("#emailMaskLayer").show();
	actionTypeTagId = "sendMailActionType";
	postRequest('sendMailForm',{actionType:'sendEmail',showSplash:true,onComplete:function(responseText){
		hideSplash();
		if (responseText == 'success'){
			jAlert('发送成功');
			$("#emailMaskLayer").hide();
			
		}else{
			jAlert('发送失败');
			$("#emailMaskLayer").hide();
		} 
	}});	
}

var insertBox;
function showInsertBox() {
	if (!insertBox) {
		insertBox = new PopupBox('insertBox', '新增周报', {
			size : 'big',
			height : '300px',
			width : '450px',
			top : '30px'
		});
	}
	var url = "index?ProcWeeklyManageEdit&actionType=&operaType=insert";
	insertBox.sendRequest(url);
}

function showAgainBox() {
	if (!insertBox) {
		insertBox = new PopupBox('insertBox', '重新提取周报', {
			size : 'big',
			height : '300px',
			width : '450px',
			top : '30px'
		});
	}
	var url = "index?ProcWeeklyManageEdit&actionType=&operaType=again";
	insertBox.sendRequest(url);
}

var queryBox;
function showQueryBox() {
	if (!queryBox) {
		queryBox = new PopupBox('queryBox', '项目周报过滤查询', {
			size : 'big',
			height : '290px',
			width : '500px',
			top : '30px'
		});
	}
	var url = "index?ProcWeeklyManageQuery&actionType=";
	queryBox.sendRequest(url);
}

var displayCountBox;
function setDisplayCountBox() {
	var limitNum = $("#limitNum").val();
	if (!displayCountBox) {
		displayCountBox = new PopupBox('displayCountBox', '设置展示条数', {
			size : 'big',
			height : '150px',
			width : '400px',
			top : '30px'
		});
	}
	var url = "index?ProcWeeklyManageSetDisplayCount&actionType=&operaType=query&num="+limitNum;
	displayCountBox.sendRequest(url);
}

function queryWeekly() {
	$("#startTime").val($("#START_TIME").val());
	$("#endTime").val($("#END_TIME").val());
	actionTypeTagId = "queryWeeklyActionType";
	formTagId = "queryWeeklyForm";
	doSubmit({actionType:'prepareDisplay'});	
}

function saveDisplayCount(num){
	actionTypeTagId = "queryWeeklyActionType";
	formTagId = "queryWeeklyForm";
	var limitNum = $("#limitNum").val(num);
	doSubmit({actionType:'saveDisplayCount'});	
}
function refreshPage(){
	actionTypeTagId = "queryWeeklyActionType";
	formTagId = "queryWeeklyForm";
	
	
	doSubmit({actionType:'prepareDisplay'});	
}
</script>
<style type="text/css">
.prompt-div{
    text-align: center;
    font-size: 23px;
    margin-top: 70px;
}
.weekly-table{width:99%;border:1px solid #D9D9D9;border-collapse:collapse}
.weekly-table td{border:1px solid #D9D9D9;}
.bartdx{    cursor: pointer; text-align: center; color: #333;font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 13px;padding: 4px 4px; height: 15px;line-height: 15px;}
#emailPreview .xheTool{display:none}

.sk-wave {
  margin: 200px auto;
  width: 250px;
  height: 40px;
  text-align: center;
  font-size: 10px; }
  .sk-rect-top{
  background-color: darkgray;
   
    height: 100%;
    width: 6px;
    display: inline-block;
    -webkit-animation: sk-waveStretchDelay 1.2s infinite ease-in-out;
            animation: sk-waveStretchDelay 1.2s infinite ease-in-out;
  }
  .sk-wave .sk-rect {
    /*background-color: #333;*/
   font-size:30px;
    height: 100%;
    width: 30px;
    display: inline-block;
    -webkit-animation: sk-waveStretchDelay 1.2s infinite ease-in-out;
            animation: sk-waveStretchDelay 1.2s infinite ease-in-out; }
  .sk-wave .sk-rect1 {
    -webkit-animation-delay: -1.2s;
            animation-delay: -1.2s; }
  .sk-wave .sk-rect2 {
    -webkit-animation-delay: -1.1s;
            animation-delay: -1.1s; }
  .sk-wave .sk-rect3 {
    -webkit-animation-delay: -1s;
            animation-delay: -1s; }
  .sk-wave .sk-rect4 {
    -webkit-animation-delay: -0.9s;
            animation-delay: -0.9s; }
  .sk-wave .sk-rect5 {
    -webkit-animation-delay: -0.8s;
            animation-delay: -0.8s; }

@-webkit-keyframes sk-waveStretchDelay {
  0%, 40%, 100% {
    -webkit-transform: scaleY(0.4);
            transform: scaleY(0.4); }
  20% {
    -webkit-transform: scaleY(1);
            transform: scaleY(1); } }

@keyframes sk-waveStretchDelay {
  0%, 40%, 100% {
    -webkit-transform: scaleY(0.4);
            transform: scaleY(0.4); }
  20% {
    -webkit-transform: scaleY(1);
            transform: scaleY(1); } }	
</style>
</head>
<body>
  <div  style="position:fixed; left:0px;top:0px;background: #d9e9ff;width:100%; ">
   <table class="queryTable" style="border:none;background:none;">
	   <tr>
	        <td>
	         &nbsp; 开始日期<input id="START_TIME" label="起始时间" name="START_TIME" type="text" value="<%=pageBean.inputDate("startTime")%>" size="9" class="text" /><img id="ST_TIMEPicker" src="images/calendar.gif" width="16" height="16" style="vertical-align: sub;" alt="日期/时间选择框" />
	                   结束日期<input id="END_TIME" label="结束日期" name="END_TIME" type="text" value="<%=pageBean.inputDate("endTime")%>" size="9" class="text" /><img id="ET_TIMEPicker" src="images/calendar.gif" width="16" height="16" style="vertical-align: sub;" alt="日期/时间选择框" />
	           &nbsp;<input type="button" name="button" id="button" value="查询" class="formbutton" onclick="queryWeekly()" />
	          <!--  &nbsp;<input type="button" name="button" id="button" value="设置" class="formbutton" onclick="setDisplayCountBox()" /> -->
	           &nbsp;<input type="button" name="button" id="button" value="新增" class="formbutton" onclick="showInsertBox()" />
	        </td>
	  </tr>
   </table>
  </div>
  <div style="padding-top:30px;">
  <div class="content" style="height:100%;">
   <%  List<DataRow> weeklyList = (List<DataRow>)pageBean.getRsList();
	 int paramSize = pageBean.listSize();
     for(int i=0;i<paramSize;i++){%> 
     
	  	<form id="weeklyForm<%=i%>" name="weeklyForm<%=i%>" method="post" action="<%=pageBean.getHandlerURL()%>">
		    <input type="hidden" name="actionType" id="actionType<%=i%>" />
		  	<div  style="margin-bottom:20px">
				<table cellspacing="0" cellpadding="0" style="width:100%;margin-left:1px;">
					<tr>
						<td class="header">
							<span style="height: 30px;line-height:30px;font-weight:bold">
								&nbsp;名称：<%=pageBean.inputValue(i,"PWI_NAME")%> &nbsp;&nbsp;
							</span>
							<div id="__ToolBar__" style="padding-right: 10px; position: relative;">
								<table border="0" cellpadding="0" cellspacing="1" style="position: absolute;top:2px;right:20px">
									<tr>
									    <%if(!"SEND_OVER".equals(pageBean.inputValue(i,"PWI_STATE"))){%>
										    <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" hotKey="D" align="center" onclick="showAgainBox()"><input value="&nbsp;" title="重新提取" type="button" class="repeatExtractImgBtn" />重新提取</td>
											<td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="saveWeeklyWork(<%=i%>)"><input value="&nbsp;" type="button" class="saveImgBtn" id="saveImgBtn" title="保存" />保存</td>
										    <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" hotKey="D" align="center" onclick="createTrace(<%=i%>)"><input value="&nbsp;" title="生成追踪" type="button" class="createTrackImgBtn" />生成追踪</td>
									    	 <%if("TRACK_OVER".equals(pageBean.inputValue(i,"PWI_STATE"))){%>
											 <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" hotKey="D" align="center" onclick="openEmailPreview(<%=i%>)"><input value="&nbsp;" title="邮件预览" type="button" class="emailPreImgBtn" />邮件预览</td></td>
										     <%}%>
									    <%}%>
									</tr>
								</table>
							</div>      		
	      				</td>    	
					</tr>
					<tr>
		     		 	<td >
	          				<textarea style="width:99%;" id="emailContent<%=i%>" name="emailContent" cols="45" rows="5" class="xheditor {skin:'o2007blue',tools:'Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,List,Outdent,Indent,Link,Unlink,Fullscreen'}">
								<%=pageBean.inputValue(i,"PWI_EMAILL_THEME")%>
							</textarea>
	          			</td>
	        		</tr>
	        		<tr>
		     		 	<td >
	          				<div id="weeklyTable<%=i%>">
		          				<table class="weekly-table" >
		          					<tr  style="color: #ffffff;background-color: green;">
		          						<td style="width:7%;text-align:center;">分类</td>
		          						<td style="width:40%;text-align:center;">内容说明</td>
		          						<td style="width:11%;text-align:center;">负责人</td>
		          						<td style="width:8%;text-align:center;">工作量（天）</td>
		          						<td style="width:7%;text-align:center;">开始时间</td>
		          						<td style="width:7%;text-align:center;">当前状态</td>
		          						<td style="width:20%;text-align:center;">原因说明</td>
		          					</tr>
		          					<tr>
		          						<td rowspan=<%=pageBean.inputValue(i,"thisWeeklyListSize")%> style="text-align:center;">本周总结</td>
		          					
		          					 <% List<DataRow> list= (List<DataRow>)pageBean.getAttribute(i, "thisWeeklyList");
						     	 	  for(int j=0;j<list.size();j++){
						     			DataRow row=(DataRow)list.get(j);
						    		  %>
						    		   <%if(j!=0){%><tr><%}%>
			          						<td ><%=row.get("PWD_CONTENT")%></td>
			          						<td style="text-align:center;"><%=row.stringValue("PWD_CHARGE")%></td>
			          						<td style="text-align:center;"><%=row.stringValue("PWD_WORKLOAD")%></td>
			          						<td style="text-align:center;"><%=row.stringValue("PWD_SATRT_TIME")%></td>
			          						<td style='text-align:center;<%=row.stringValue("color")%>' ><%=row.stringValue("PWD_STATE_NAME")%></td>
			          						<td ><textarea name="thisWeekItemExplain<%=j%>" rows="1" style="width:98%;border:0;resize: vertical;"><%=row.stringValue("PWD_EXPLAIN")%></textarea></td>
			          						<input type="hidden" name="thisWeekItemId<%=j%>" id="thisWeekItemId<%=j%>" value='<%=row.stringValue("PWD_ID")%>'/>
			          					</tr>
		          					<%}%>
		          					<tr>
		          						<td rowspan=<%=pageBean.inputValue(i,"nextWeeklyListSize")%> style="text-align:center;">下周计划</td>
		          					
		          					<% list= (List<DataRow>)pageBean.getAttribute(i, "nextWeeklyList");
						     	 	  for(int j=0;j<list.size();j++){
						     			DataRow row=(DataRow)list.get(j);
						    		%>
			          					 <%if(j!=0){%><tr><%}%>
			          						<td ><%=row.get("PWD_CONTENT")%></td>
			          						<td style="text-align:center;"><%=row.stringValue("PWD_CHARGE")%></td>
			          						<td style="text-align:center;"><%=row.stringValue("PWD_WORKLOAD")%></td>
			          						<td style="text-align:center;"><%=row.stringValue("PWD_SATRT_TIME")%></td>
			          						<td style='text-align:center;<%=row.stringValue("color")%>' ><%=row.stringValue("PWD_STATE_NAME")%></td>
			          						<td ><textarea name="nextWeekItemExplain<%=j%>" rows="1" style="width:98%;border:0;resize: vertical;"><%=row.stringValue("PWD_EXPLAIN")%></textarea></td>
			          						<input type="hidden" name="nextWeekItemId<%=j%>" id="nextWeekItemId<%=j%>" value='<%=row.stringValue("PWD_ID")%>'/>
			          					</tr>
		          					<%}%>
		          					<tr>
		          						<td rowspan=<%=pageBean.inputValue(i,"followWeeklyListSize")%> style="text-align:center;">后续计划</td>
		          					
		          					
		          					<% list= (List<DataRow>)pageBean.getAttribute(i, "followWeeklyList");
						     	 	  for(int j=0;j<list.size();j++){
						     			DataRow row=(DataRow)list.get(j);
						    		%>
			          					 <%if(j!=0){%><tr><%}%>
			          						<td ><%=row.get("PWD_CONTENT")%></td>
			          						<td style="text-align:center;"><%=row.stringValue("PWD_CHARGE")%></td>
			          						<td style="text-align:center;"><%=row.stringValue("PWD_WORKLOAD")%></td>
			          						<td style="text-align:center;"><%=row.stringValue("PWD_SATRT_TIME")%></td>
			          						<td style='text-align:center;<%=row.stringValue("color")%>' ><%=row.stringValue("PWD_STATE_NAME")%></td>
			          						<td ><textarea name="followWeekItemExplain<%=j%>" rows="1" style="width:98%;border:0;resize: vertical;"><%=row.stringValue("PWD_EXPLAIN")%></textarea></td>
			          						<input type="hidden" name="followWeekItemId<%=j%>" id="followWeekItemId<%=j%>" value='<%=row.stringValue("PWD_ID")%>'/>
			          					</tr>
		          					<%}%>
		          				</table>
	          				</div>
	          			</td>
	        		</tr>
				</table>
		    </div>
            <input type="hidden" name="operaType" id="operaType" value='update'/>
            <input type="hidden" name="PPA_ID" id="PPA_ID" value='<%=pageBean.inputValue(i,"PPA_ID")%>'/>    
            <input type="hidden" name="PWI_START_TIME" id="PWI_START_TIME" value='<%=pageBean.inputValue(i,"PWI_START_TIME")%>'/>
            <input type="hidden" name="PWI_ID" id="PWI_ID" value='<%=pageBean.inputValue(i,"PWI_ID")%>'/>
		 </form>
  <%}%>
  
  
   </div>
   </div>
   <%if(paramSize==0){%><div class="prompt-div">没有追踪记录</div><%}%> 
   <div id="maskLayer" style="width:100%;height:100%;background-color: #B3B3B3;position:fixed;left:0px;top:0px;opacity:0.50;display:none"></div>
    <div id="emailMaskLayer" style="width:100%;height:100%;position:fixed;left:0px;top:0px;z-index:321;opacity:0.9;display:none">
     <div class="sk-wave" >
      	<div class="sk-rect-top sk-rect1"></div>
        <div class="sk-rect-top sk-rect2"></div>
        <div class="sk-rect-top sk-rect3"></div>
        <div class="sk-rect-top sk-rect4"></div>
        <div class="sk-rect-top sk-rect5"></div>
      </div>
	 </div>
   <div  id="emailPreview" class="emailPreview" style="width:80%;height:70%;background-color: #edf7f7;position: absolute; left:100px;top:30px;display:none;">
   <form id="sendMailForm" name="sendMailForm" method="post" action="<%=pageBean.getHandlerURL()%>">
   <input type="hidden" name="actionType" id="sendMailActionType" />
   <div id="emailPreviewBanner" style="background-color: #666699;width:100%;height:30px;cursor: move; "  >
   		<span style="line-height:30px;margin-left:5px;color:#FFFFFF">邮件预览</span>
   		<span  style="margin-right:5px;float:right;line-height:30px;color:#FFFFFF" align="center" onclick="closeEmailPreview()"><input value="&nbsp;" type="button" class="delImgBtn" id="delImgBtn" title="关闭" /><a style="cursor:pointer">关闭</a></span>
   </div>
   <table>
	    <tr>
	  		<td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="sendEmail()"><input value="&nbsp;" type="button" class="sendMailImgBtn" id="sendMailImgBtn" title="发送邮件" />发送邮件</td>
	  	</tr>
   </table>
   <table style="margin-left:5px;width:99%">
	  	<tr>
	  		<td style="width:60px"><span>发件邮箱:</span></td><td><input name="emailOutbox" type="text" readonly="readonly" value="<%=pageBean.inputValue("outboxInfo") %>"/></td>
	  	</tr>
	  	<tr>
	  		<td ><span>收件邮箱:</span></td><td><input name="emailInboxName" type="text" style="width:100%" readonly="readonly" value="<%=pageBean.inputValue("inboxInfoName") %>"/></td>
	  	</tr>
	  	<tr>
	  		<td><span>邮件标题:</span></td><td><input name="emailTitle" type="text" style="width:100%"/></td>
	  	</tr>
   </table>
   <div style="width:100%;text-align:center;margin-top:3px">
   		<textarea style="width:99%;" id="emailSubject" name="emailSubject"  cols="45" rows="20" class="xheditor {skin:'vista',tools:'',height:'300'}"></textarea>
   </div>
     <input type="hidden" name=emailServer id="emailServer" value="<%=pageBean.inputValue("emailServer") %>" />
     <input type="hidden" name="emailPost" id="emailPost" value="<%=pageBean.inputValue("emailPost") %>" />
     <input type="hidden" name="emailPassWord" id="emailPassWord" value="<%=pageBean.inputValue("emailPassWord") %>" />
     <input type="hidden" name="emailWeeklyId" id="emailWeeklyId" value="" />
     <input name="emailInbox" type="hidden" style="width:100%" value="<%=pageBean.inputValue("inboxInfo") %>"/>
   </form>
   </div>
   
   <form id="queryWeeklyForm" name="queryWeeklyForm" method="post" action="<%=pageBean.getHandlerURL()%>">
	   <input type="hidden" name="actionType" id="queryWeeklyActionType" />
	   <input type="hidden" name="startTime" id="startTime"  value="<%=pageBean.inputDate("startTime")%>"/>
	   <input type="hidden" name="endTime" id="endTime"  value="<%=pageBean.inputDate("endTime")%>" />
	   <input type="hidden" name="limitNum" id="limitNum" value="<%=pageBean.inputValue("limitNum") %>" />
   </form>
</body>
<script type="text/javascript">

initCalendar('START_TIME','%Y-%m-%d','ST_TIMEPicker');
datetimeValidators[0].set("yyyy-MM-dd").add("START_TIME");
initCalendar('END_TIME','%Y-%m-%d','ET_TIMEPicker');
datetimeValidators[0].set("yyyy-MM-dd").add("END_TIME");
initDetailOpertionImage();
</script>
</html>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
